/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.sais.eswn.core;

import java.util.HashMap;
import org.sais.eswn.card.Card;
import org.sais.eswn.card.CardSet;
import org.sais.eswn.deck.Deck;
import org.sais.eswn.tool.Tools;

/**
 *
 * @author Romulus
 */
public class Player {

    public static final int ICH = 0;
    public static final int OPP = 1;
    private String mName;
    private Deck mInitDeck = new Deck();
    private CardSet mDeck = new CardSet();
    private CardSet mField = new CardSet();
    private CardSet mGrave = new CardSet();
    private CardSet mRFG= new CardSet();

    public void moveCard(int source, int destination, String cardno) {
        HashMap<Integer, CardSet> map = new HashMap<Integer, CardSet>();
        map.put(GameCore.REGION_DECK, mDeck);
        map.put(GameCore.REGION_FIELD, mField);
        map.put(GameCore.REGION_GRAVE, mGrave);
        map.put(GameCore.REGION_RFG, mRFG);

        CardSet sourceSet = map.get(source);
        CardSet destSet = map.get(destination);

        Card c = sourceSet.pop(cardno);
        if (c == null) {
            destSet.add(Tools.getCard(cardno));
        } else {
            destSet.add(c);
        }
    }

    public Deck getInitialDeck() {
        return mInitDeck;
    }

    public CardSet getRamainingDeck() {
        return mDeck;
    }

    public CardSet getField() {
        return mField;
    }

    public CardSet getGrave() {
        return mGrave;
    }

    public CardSet getRFG() {
        return mRFG;
    }

    public String getName() {
        return mName;
    }

    public String getDeckName() {
        return mInitDeck.getDeckname();
    }

    public void setDeck(Deck deck) {
        mInitDeck = deck;
        mDeck.clear();
        mGrave.clear();
        mField.clear();
        mRFG.clear();
        for (String s : deck.listCardnos()) {
            mDeck.add(Tools.getCard(s));
        }
    }

    public void setName(String name) {
        mName = name;
    }
}
